package org.eenie.kdassistant.ui;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import org.eenie.kdassistant.R;

import java.util.List;

/**
 * Created by Eenie on 2017/8/1.
 * Email: eeniework@gmail.com
 * Des:
 */

public class ExpressAdapter extends BaseAdapter {

    List<ExpressEntity> mExpressEntities;

    Context mContext;

   public ExpressAdapter(Context context,List<ExpressEntity> datas) {
       mContext = context;
       mExpressEntities = datas;
    }


    @Override
    public int getCount() {
        return mExpressEntities.size();
    }

    @Override
    public Object getItem(int position) {
        return mExpressEntities.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        TextView tvInfo = null;

        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_express, null);
            tvInfo = (TextView) convertView.findViewById(R.id.tv_express);
            convertView.setTag(tvInfo);
        } else {
            tvInfo = (TextView) convertView.getTag();
        }

        tvInfo.setText(String.format("%s ---- %s",mExpressEntities.get(position).getSrc(),mExpressEntities.get(position).getExpress()));
        return convertView;
    }


    public void refreshItem(ExpressEntity entity) {



    }
}
